package hn.sigit.dao.hnd.ladmshadow;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import hn.sigit.model.hnd.ladmshadow.BAUnit;
import hn.sigit.dao.SigitDAO;

public class BAUnitDAO extends SigitDAO<BAUnit> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public static BAUnit loadBAUnitByLadmIdAndPresentationId(long ladmId, long presentationId) {
		return loadBAUnitByLadmIdAndPresentationId(getSession(), ladmId, presentationId);
	}
	public static BAUnit loadBAUnitByLadmIdAndPresentationId(Session session, long ladmId, long presentationId) {
		Criteria criteria = session.createCriteria(BAUnit.class);
		criteria.add(Restrictions.eq("ladmId", ladmId));
		criteria.add(Restrictions.eq("presentationId", presentationId));
		criteria.add(Restrictions.eq("snapshot", false));
		
		return (BAUnit)criteria.uniqueResult();
	}

}
